#include <iostream>
#include "PointsDatabase.h"

void main( int argc, int *argv[])
{
	list<string> imgPaths;
	if( !PointsDatabase::getEnvImagePaths( imgPaths ) )
	{
		return;
	}
	string ptsfile = "../Data/pts.info";
	PointsDatabase pts( ptsfile, imgPaths, NULL );

	int bins = 8;
	int counts[8];
	for( int b = 0; b < bins; b++ ) counts[b] = 0;

	PointsDatabase::const_iterator endIter = pts.end();
	for( PointsDatabase::const_iterator imIter = pts.begin(); imIter != endIter; imIter++ )
	{
		cout << "[" << imIter->first << "]" << endl;
		int t = 0;
		const PointsDatabase::PointsInImage* impts = &imIter->second;
		for( PointsDatabase::PointsInImage::const_iterator piter = impts->begin();
			piter != impts->end(); piter++ )
		{
			cout << "\t" << piter->loc.x << "," << piter->loc.y << endl;
			int b = cvRound( bins * (piter->gradRad / 2*3.14152f + 1) ) % bins;
			counts[b]++;
			t++;
		}
		cout << "end-line" << endl;
	}
	for( int b = 0; b < bins; b++ ) 
	{
		printf("Orientation %d has %d points.\n", b, counts[b]);
	}

}